package com.atguigu.hbase;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.client.AsyncConnection;
import org.apache.hadoop.hbase.client.Connection;
import org.apache.hadoop.hbase.client.ConnectionFactory;

import java.util.concurrent.CompletableFuture;

/**
 * Created by 黄凯 on 2023/6/30 0030 18:53
 *
 * @author 黄凯
 * 永远相信美好的事情总会发生.
 * <p>
 * Connection : 由ConnectionFactory来创建。
 */
public class Hbase01_Connection {

    public static void main(String[] args) {

        try {
            Configuration conf = HBaseConfiguration.create();
            conf.set("hbase.zookeeper.quorum", "hadoop102,hadoop103,hadoop104");
            // 创建同步的Connection对象
            Connection connection = ConnectionFactory.createConnection(conf);

            // 创建异步的Connection对象
            CompletableFuture<AsyncConnection> asyncConnection = ConnectionFactory.createAsyncConnection(conf);
            System.out.println(connection);
            System.out.println(asyncConnection.get());
            connection.close();

            asyncConnection.get().close();

        } catch (Exception e) {
            throw new RuntimeException(e);
        }

    }

}
